package code.logic {

import code.Model;
import code.vo.Category;

import logging.Logger;

import mx.controls.AdvancedDataGrid;
	

public class ExpandCollapseFoldersDelegate {
	
	private static const LOG: Logger = Logger.getLogger("code.logic.ExpandCollapseFoldersDelegate");
	
	private static const GRID_NEEDED: AdvancedDataGrid = Model.instance.neededTopicsAdvancedDataGridHack;
	private static const GRID_OFFERED: AdvancedDataGrid = Model.instance.offeredTopicsAdvancedDataGridHack;
	
	public function expandFolders(): void {
		LOG.finer("expandFolders() invoked");
		
		GRID_OFFERED.expandAll();
		GRID_NEEDED.expandAll();
		/*
		for each(var ocat: Category in Model.instance.offeredCategories) {
			//GRID_OFFERED.expandItem(ocat, true);
			GRID_OFFERED.expandChildrenOf(ocat, true);
		}
		*/
		
		/*
		for each(var ncat: Category in Model.instance.offeredCategories) {
			GRID_OFFERED.expandItem(ocat, true);
			
		}
		*/
	}
	
	public function collapseFolders(): void {
		LOG.finer("collapseFolders() invoked");
		
		GRID_OFFERED.collapseAll();
		GRID_NEEDED.collapseAll();
	}
	
	
	private static var INSTANCE: ExpandCollapseFoldersDelegate; 
	public function ExpandCollapseFoldersDelegate(singletonEnforcer: SingletonEnforcer) { }
	public static function get instance(): ExpandCollapseFoldersDelegate {
		if(INSTANCE == null) { INSTANCE = new ExpandCollapseFoldersDelegate(new SingletonEnforcer()); }
		return INSTANCE;
	}

	

}
}
class SingletonEnforcer { }